import request from "@/utils/request";

/**
 * banner管理接口
 */

//获取banner列表接口
export const getBannerListRequest = (data) => {
  return request({
    url: "/management-admin/banner/queryByPage",
    method: "post",
    data,
  });
};

//上传新增接口
export function uploadFileRequest(file, name, sort, isShow) {
  const data = new FormData();
  data.append("file", file);
  data.append("name", name);
  data.append("sort", sort);
  data.append("isShow", isShow);
  return request({
    url: "/management-admin/banner/add",
    method: "post",
    data,
  });
}

//删除banner接口
export const deleteBannerRequest = (data) => {
  return request({
    url: "/management-admin/banner",
    method: "post",
    data,
  });
};

//编辑banner 接口
export const editBannerRequest = (file, name, sort, isShow, id) => {
  const data = new FormData();
  if (file) {
    data.append("file", file);
  }
  data.append("name", name);
  data.append("sort", sort);
  data.append("isShow", isShow);
  data.append("id", id);

  return request({
    url: "/management-admin/banner/edit",
    method: "post",
    data,
  });
};
